package com.hengtiansoft.lfy.utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.hengtiansoft.lfy.activity.MainActivity;
import com.hengtiansoft.lfy.chart.activity.NewFriendsMsgActivity;
import com.hengtiansoft.lfy.constants.Constants;

/**
 * Created by Administrator on 2017/1/18.
 */

public class NotificationClickReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if(Constants.CHART_MESSAGE.equals(intent.getStringExtra(Constants.CHART_MESSAGE))) {
            //todo 跳转之前要处理的逻辑
            Intent newIntent = new Intent(context, MainActivity.class);
            newIntent.putExtra(Constants.CHART_MESSAGE, Constants.CHART_MESSAGE);
            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            context.startActivity(newIntent);
        }else if(Constants.NEW_FRIEND_MESSAGE.equals(intent.getStringExtra(Constants.NEW_FRIEND_MESSAGE))){
            Intent newIntent = new Intent(context, NewFriendsMsgActivity.class);
            //newIntent.putExtra(Constants.NEW_FRIEND_MESSAGE, Constants.NEW_FRIEND_MESSAGE);
            newIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            context.startActivity(newIntent);
        }
    }
}
